<template>
  <el-form ref="form" :model="formData" :label-width="labelWidth+'px'" size="mini">
    <el-row class="flex-row">
      <el-col v-for="(item,index) in detailsList" :span="item.span?item.span:24" :key="index">
        <el-form-item v-if="item.type=='slot'">
          <slot :name="item.field">
          </slot>
        </el-form-item>
        <el-form-item v-else :label="item.label">
          <template #label="scope">
            <el-tooltip class="item" effect="light" :content="item.label+''" placement="top-start">
              <el-button class="btn-content-label" style="color:#606266 !important;text-align:right;padding:0 10px;" type="text">{{
                  item.label
                }}
              </el-button>
            </el-tooltip>
          </template>
          <el-tooltip v-if="formData[item.field]!=''" class="item" effect="dark" :content="formData[item.field]+''" placement="top-start">
            <el-button class="btn-content" style="color:#606266 !important;padding:0 10px;" type="text">{{
                formData[item.field]
              }}
            </el-button>
          </el-tooltip>
          <div v-else></div>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
export default {
  name: 'hk-details',
  props: {
    labelWidth: {
      type: String,
      default() {
        return '100'
      }
    },
    detailsList: {
      type: Array,
      default() {
        return []
      }
    },
    formData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {}
  },
  watch: {
    formData: {
      handler(newVal) {
    
      }
    }
  },
  methods: {}
}
</script>

<style lang="scss" scoped>
.flex-row{
  display: flex;
  flex-wrap: wrap;
}
::v-deep .el-form-item {
  margin-bottom: 0 !important;
  border-top: 1px solid #E5E5E5;
  border-bottom: 1px solid #E5E5E5;
  margin-top: -1px;
}

::v-deep .el-form-item__label {
  background: #f9fafd !important;
  font-weight: 100;
  line-height:30px;
}

::v-deep .el-form-item__content {
  overflow: hidden; //溢出隐藏
  white-space: nowrap; //禁止换行
  text-overflow: ellipsis; //...
}

::v-deep .btn-content {
  width: 100%;
  span {
    width: 100%;
    text-align:left;
    font-size: 14px !important;
    display: inline-block !important;
    overflow: hidden !important; //溢出隐藏
    white-space: nowrap !important; //禁止换行
    text-overflow: ellipsis !important; //...
  }
}
::v-deep .btn-content-label{
  width:100%;
  span{
    width:100%;
    font-size: 14px;
    display: inline-block !important;
    overflow: hidden !important; //溢出隐藏
    white-space: nowrap !important; //禁止换行
    text-overflow: ellipsis !important; //...
  }
}

</style>
